#########################
### Code to produce Supplementary Materials S11
### Analysis of colonial archives in the Archivo General de la Nacion 
##########################

## Files
agn_s <- read.csv("C:/Users/franc/Dropbox/PhD/Edgar_Tlaxcala/AGN/agn_s.csv")

# Table by topic
# Table S11.1
agn_count <- agn_s %>% count(topic) %>% filter(topic!="") %>% arrange(desc(n))

print(xtable(head(agn_count, 10)),include.rownames=FALSE)


# Plot total vs indios per year
# Figure S11.1
agn_year <- agn_s %>% filter(year>=1521, year<=1820) %>% group_by(year) %>% summarise(total=n())
plot(agn_year)
g <- ggplot(agn_year, aes(x=year, y=total)) + geom_line() 
g <- g + theme_bw()
g 
#ggsave(g, file="C:/Users/franc/Dropbox/PhD/dissertation/paper_colonialism_liberalims/tex/FINAL_version_2021/online_appendix/total_files_agn.png", width=8)

### For indios
## Different ways to refer to the juzgado
## Indios only
## 
agn_in <- agn_s %>% filter(topic=="indios")
sort(unique(agn_in$productor))
agn_in_c <- agn_in %>% count(productor)

##########################

